﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DropDownList1.Items.Add("福建");
                DropDownList1.Items.Add("江西");
                DropDownList1.Items.Add("广西");
                DropDownList2.Items.Add("龙岩");
                DropDownList2.Items.Add("厦门");
                DropDownList2.Items.Add("福州");
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string province = DropDownList1.SelectedValue;
            DropDownList2.Items.Clear();

            if (province == "福建")
            {
                DropDownList2.Items.Add("龙岩");
                DropDownList2.Items.Add("厦门");
                DropDownList2.Items.Add("福州");
            }
            else if(province == "江西")
            {
                DropDownList2.Items.Add("九江");
                DropDownList2.Items.Add("南昌");
                DropDownList2.Items.Add("赣州");
            }
            else
            {
                DropDownList2.Items.Add("柳州");
                DropDownList2.Items.Add("贵港");
                DropDownList2.Items.Add("崇左");
            }
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string hobby = "你的爱好是:";
            for (int i = 0; i < CheckBoxList1.Items.Count; i++)
            {
                if (CheckBoxList1.Items[i].Selected)
                {
                    hobby += CheckBoxList1.Items[i] + " ";
                }
            }
            Literal1.Text = $"用户名：{TextBox1.Text}，性别:{RadioButtonList1.SelectedValue}，籍贯：{DropDownList1.SelectedValue}省，{DropDownList2.SelectedValue}市，其它信息:{TextBox3.Text}，爱好:{hobby}";

        }
    }
}